package com.zoe.app.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextListener;

import javax.servlet.ServletRequestEvent;
import javax.servlet.annotation.WebListener;

/**
 * @author Zoe.Zhang
 * @date 2021/10/10
 * @description
 */
@WebListener
public class DynamicListener extends RequestContextListener {
    private static final Logger log = LoggerFactory.getLogger(DynamicListener.class);

    public DynamicListener() {
        super();
        log.error("listener-init");
    }

    /**
     * 每次请监听到请求进来的时候都会触发
     *
     * @param requestEvent
     */
    @Override
    public void requestInitialized(ServletRequestEvent requestEvent) {
        log.error("listener-requestInitialized");
        super.requestInitialized(requestEvent);
    }

    /**
     * 每次请监听到请求结束的时候都会触发
     *
     * @param requestEvent
     */
    @Override
    public void requestDestroyed(ServletRequestEvent requestEvent) {
        log.error("listener-requestDestroyed");
        super.requestDestroyed(requestEvent);
    }
}
